<?php

class productPreviewComponents extends myComponents{

	public function executeRender(){
		$q = Doctrine_Query::create()
			->from('ProductGroup pg')
			->select('pg.*, pgt.* , pgvp.* , p.*, pp.*, pt.*')
			->innerJoin('pg.Products pgvp')
			->innerJoin('pgvp.Product p')
			->where('pg.parameter = ?', 'index_page_group')
			->innerJoin('pg.StructureProductGroup spg')
			->leftJoin('p.ProductPictures pp')
			->innerJoin('pg.Translation pgt WITH pgt.lang = ?', $this->getUser()->getCulture())
			//->innerJoin('spg.Structure s WITH s.id = ?', $this->getRoute()->getObject()->getId())
			->innerJoin('p.Translation pt WITH pt.lang = ? AND pt.name != ""', $this->getUser()->getCulture())
			->limit(5)
			->setHydrationMode(Doctrine::HYDRATE_ARRAY);


		$this->productGroups = $q->execute();
//		print_r($this->productGroups);
//		exit;
		$productPKs = array();
		foreach($this->productGroups as $group){
			$c = 0;
			foreach($group['Products'] as $product){
				if($c == 3)break;
				$productPKs[] = $product['Product'];
				++$c;

			}
		}

		$this->productLinks = LinkGen::getInstance(LinkGen::PRODUCT)->collectionLinks($productPKs);



	}
}